package com.yf.pagination;

import com.google.common.collect.Lists;
import com.yf.util.PageUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

import java.io.Serializable;
import java.util.List;

/**
 * 分页包装类
 *
 * @author wangbiao
 * @date 2016-08-18 14：07
 */
@ApiModel(value = "分页包装类")
public class Page implements Serializable {

    private static final long serialVersionUID = 6913615974516038024L;

    /**
     * 当前页
     */
    @ApiModelProperty(name = "currentPage", value = "当前页")
    private Integer currentPage = PageUtils.DEFAULT_CURRENT_PAGE;

    /**
     * 每页条数
     */
    @ApiModelProperty(name = "pageSize", value = "每页条数")
    private Integer pageSize = PageUtils.DEFAULT_PAGE_SIZE;

    /**
     * 总记录条数
     */
    @ApiModelProperty(name = "totalRows", value = "总记录条数")
    private Long totalRows;

    /**
     * 总页数
     */
    @ApiModelProperty(name = "totalPages", value = "总页数")
    private Integer totalPages;

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = PageUtils.getValidPageParams(currentPage, PageUtils.PageParamsType.CURRENT_PAGE);
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = PageUtils.getValidPageParams(pageSize, PageUtils.PageParamsType.PAGE_SIZE);
    }

    public Long getTotalRows() {
        return totalRows;
    }

    public void setTotalRows(Long totalRows) {
        this.totalRows = totalRows;
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }

}
